package com.iflysse.dao;

import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.iflysse.entity.Account;
import com.iflysse.dto.UserLoginDto;

public interface AccountDao {

    /**
     * 根据account_number 和 password 或者 email 和password 查询账号信息
     * @param form
     * @return
     */
    @Select("select * from tb_account \r\n"
    		+ "where account_number=#{userName} and password=#{passWord}\r\n"
    		+ "OR\r\n"
    		+ "email=#{userName} and password=#{passWord}")
    Account findUserByAccountInfoAndPassword(UserLoginDto form);

    /**
     * 更新最后登录时间
     * @param accountId 账户编号
     * @return
     */
    @Update("update tb_account set last_login_date=now() where account_id=#{accountId}")
    int updateLoginDate(String accountId);
    
    /**
     * 根据accountId 查询用户
     * @param userPoReq
     * @return
     */
    @Select("select * from tb_account where account_id= #{accountId} and role=#{role}")
    Account findUserByAccountIdAndRole(String accountId, String role);


}